package Tree;

public class Test {

    public static void main(String[] args) {
        Tree tree=new Tree();

        TreeNode treeNode0 = new TreeNode(1,"nn");
        TreeNode treeNode1 = new TreeNode(2,"nn");
        TreeNode treeNode2 = new TreeNode(3,"nn");
        TreeNode treeNode3 = new TreeNode(4,"nn");
        TreeNode treeNode4 = new TreeNode(5,"nn");
        TreeNode treeNode5 = new TreeNode(6,"nn");
        TreeNode treeNode6 = new TreeNode(7,"nn");
        TreeNode treeNode7 = new TreeNode(8,"nn");
        TreeNode treeNode8 = new TreeNode(9,"nn");
        TreeNode treeNode9 = new TreeNode(10,"nn");

        treeNode0.setLeft(treeNode1);
        treeNode0.setRight(treeNode2);
        treeNode1.setLeft(treeNode3);
        treeNode1.setRight(treeNode4);
        treeNode2.setLeft(treeNode5);
        treeNode2.setRight(treeNode6);
        treeNode5.setLeft(treeNode7);
        treeNode7.setRight(treeNode8);
        treeNode8.setLeft(treeNode9);

        tree.setRootNode(treeNode0);

        tree.frontErgodic();
        System.out.println("========");
        tree.middleErgodic();
        System.out.println("========");
        tree.behindErgodic();
        System.out.println("======================================================");

        System.out.println(tree.preSearch(5).getId());
        System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        System.out.println(tree.middleSearch(5).getId());
        System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        System.out.println(tree.behindSearch(5).getId());
        System.out.println("///////////////////////////////////////////////////////");


        tree.delTreeNode(10);

        tree.frontErgodic();
        System.out.println("//////");
        tree.middleErgodic();
        System.out.println("//////");
        tree.behindErgodic();
        tree.delTreeNodeAll(2);
        tree.frontErgodic();
        tree.middleErgodic();
        tree.behindErgodic();

    }
}
